﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <%-- <mcs:UC_GridView ID="ud_grid" runat="server" PanelCode="Panel_CM_Client_Chingy" AutoGenerateColumns="False"
            AllowPaging="True" PageSize="15" AllowSorting="True" DataKeyNames="ID" Binded="False"
            ConditionString="" OrderFields="" TotalRecordCount="0">
            <Columns>
                <asp:BoundField DataField="ID" />
                <asp:BoundField DataField="FullName" />
            </Columns>
        </mcs:UC_GridView>--%>
        <%--<mcs:UC_GridView ID="UC_GridView1" runat="server" PanelCode="Panel_CM_Client_Chingy"
            AutoGenerateColumns="False" Width="100%" DataKeyNames="ID" AllowPaging="true"
            PageSize="15" AllowSorting="True" OnSelectedIndexChanged="UC_GridView1_SelectedIndexChanged">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:CheckBox ID="chkStaff_ID" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:HyperLinkField DataNavigateUrlFields="FullName" Target="_blank" DataNavigateUrlFormatString=""
                    DataTextField="FullName" HeaderText="员工姓名"></asp:HyperLinkField>
            </Columns>
        </mcs:UC_GridView>--%>
        <asp:GridView ID="GridView1" runat="server" OnPageIndexChanging="GridView1_PageIndexChanging" DataKeyNames="ID" 
            AutoGenerateColumns="False" OnRowCommand="GridView1_RowCommand" 
            AllowSorting="True">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:CheckBox ID="chkClient_ID" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="ID" HeaderText="ID" />
                <asp:BoundField DataField="Code" HeaderText="代号" />
                <asp:BoundField DataField="FullName" HeaderText="全称" />
                <asp:BoundField DataField="ShortName" HeaderText="短称" />
                <asp:BoundField DataField="Address" HeaderText="地址" />
                <asp:BoundField DataField="TeleNum" HeaderText="电话号码" />
                <asp:BoundField DataField="Fax" HeaderText="传真" />
                <asp:BoundField DataField="Email" HeaderText="Email" />                
                <asp:BoundField DataField="PostCode" HeaderText="邮编" />
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton ID="LinkButton" Text="选择" runat="server" CommandName="Choose"></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <PagerTemplate>
                当前第:
                <%--((GridView)Container.NamingContainer)就是为了得到当前的GridView控件--%>
                <asp:Label ID="LabelCurrentPage" runat="server" Text="<%# ((GridView)Container.NamingContainer).PageIndex + 1 %>"></asp:Label>
                页/共:
                <asp:Label ID="LabelPageCount" runat="server" Text="<%# ((GridView)Container.NamingContainer).PageCount %>"></asp:Label>
                页
                <%--  分页是首分页时，首页按钮不显示；上一页，下一页；分页是尾页，则尾页按钮不显示
                CommandArgument通常只在设置CommandName属性时使用，作为指定补充 CommandName 属性的参数，提供要执行的Command 事件处理程序的可选参数。例如 CommandName 属性设置为 Sort 并将 CommandArgument 属性设置为 Ascending，以指定按升序排序的命令。                
             --%>
                <%-- 首页按钮，对应了自带识别的命令参数CommandArgument--%>
                <asp:LinkButton ID="LinkButtonFirstPage" runat="server" CommandArgument="First" CommandName="Page"
                    Visible="<%# GridView1.PageIndex != 0 %>">首页</asp:LinkButton>
                <asp:LinkButton ID="LinkButtonPreviousPage" runat="server" CommandArgument="Prev"
                    CommandName="Page" Visible="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>">上一页</asp:LinkButton>
                <asp:LinkButton ID="LinkButtonNextPage" runat="server" CommandArgument="Next" CommandName="Page"
                    Visible="<%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>">下一页</asp:LinkButton>
                <asp:LinkButton ID="LinkButtonLastPage" runat="server" CommandArgument="Last" CommandName="Page"
                    Visible="<%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>">尾页</asp:LinkButton>
                转到第
                <asp:TextBox ID="txtNewPageIndex" runat="server" Width="20px" />
                页
                <%--这里将CommandArgument即使点击该按钮e.newIndex 值为3 --%>
                <asp:LinkButton ID="btnGo" runat="server" CausesValidation="False" CommandArgument="-1"
                    CommandName="Page" Text="GO" />
            </PagerTemplate>            
        </asp:GridView>
    </div>
    <asp:Button ID="btnDelete" runat="server" Text="删除" onclick="btnDelete_Click" />
    
    <asp:Panel ID="Panel1" runat="server">
        <asp:Label ID="Label1" runat="server" Text="全称"></asp:Label>
        <asp:TextBox ID="txtFullName" runat="server"></asp:TextBox><br />
        <br />
        <asp:Label ID="Label2" runat="server" Text="地址"></asp:Label>
        <asp:TextBox ID="txtAddress" runat="server"></asp:TextBox>
        <br />
        <asp:Label ID="TeleNum" runat="server" Text="电话号码"></asp:Label>
        <asp:TextBox ID="txtTeleNum" runat="server"></asp:TextBox>
        <br />
        <asp:Label ID="PostCode" runat="server" Text="Email"></asp:Label>
        <asp:TextBox ID="txtPostCode" runat="server"></asp:TextBox>
        <br />
        <asp:Button ID="btnChg" runat="server" Text="修改" onclick="btnChg_Click" />
        <asp:Button ID="btnAdd" runat="server" Text="添加" onclick="btnAdd_Click" />
    </asp:Panel>
    </form>
</body>
</html>
